package com.example.demo.ioc3;

import org.apache.catalina.core.FrameworkListener;

/**
 * IoC实现的制造车
 */
public class IocCarExample {
    public static void main(String[] args) {
        Tire tire=new Tire(20);
        Bottom bottom=new Bottom(tire);
        FrameWork frameWork=new FrameWork(bottom);
        Car car=new Car(frameWork);
        car.run();
    }
    static class Car{
        private FrameWork frameWork;
        public Car(FrameWork frameWork){
            this.frameWork=frameWork;
        }
        public void run(){
            frameWork.init();
        }

    }
    static class FrameWork{
        private Bottom bottom;
        public FrameWork(Bottom bottom){
            this.bottom=bottom;
        }
        public void init(){
            bottom.init();
        }
    }
    static class Bottom{
        private Tire tire;

        public Bottom(Tire tire){
            this.tire=tire;
        }
        public void init(){
            tire.init();
        }
    }
    static class Tire{
        private int size;

        public Tire(int size){
            this.size=size;
        }
        public void init(){
            System.out.println("轮胎尺寸:"+size);
        }

    }
}
